home *** CD-ROM | disk | FTP | other *** search
- %
- % T A B L S . S T Y (ver 3.2)
- %
- % Copyright (c) 1989, 1990, 1991, 1992, 1994 by Donald Arseneau
- % from
- % LaTeX, Copyright (c) 1985... by Leslie Lamport
- %
- % Modify LaTeX's array and tabular environments to keep text from touching
- % other text or hlines above or below. See instructions after \endinput.
- %
- %----------------------------------------------------------------------
-
- % create registers and default settings:
-
- \newdimen\tablinesep \tablinesep= 1pt \let\tablineskip=\tablinesep
- \newdimen\arraylinesep \arraylinesep= 1pt \let\arraylineskip=\arraylinesep
- \newdimen\extrarulesep \extrarulesep= 3pt
-
- \newdimen\@arstdepth \newdimen\@arstheight \newdimen\@skip@bove
-
- \let\@tarlinesep\z@ % so outermost arrays will not act nested
-
- % Change the initializations to create a smaller strut and include
- % my macros in the initialization for the preamble.
-
- \def\@array[#1]#2{% remember global variables to allow recursion:
- \edef\@unrecurse{\global\@skip@bove\the\@skip@bove
- \global\@arstheight\the\@arstheight\global\@arstdepth\the\@arstdepth}%
- % Make the strut on the first line be shorter by the linesep outside
- \let\@otarlinesep\@tarlinesep \global\@skip@bove-\@otarlinesep
- % This setup works for both tabular and array because of this test:
- \ifx\@classz\@arrayclassz \let\@tarlinesep\arraylinesep
- \else \let\@tarlinesep\tablinesep \fi
- \divide\@tarlinesep\tw@% half sep is applied to height & depth
- \let\@seesize\relax \let\@rememsize\relax \@mkpream{#2}%
- \@tempdima\arraystretch\ht\strutbox \@tempdimb\arraystretch\dp\strutbox
- \ifdim\@tarlinesep>\z@
- \def\@rememsize{\protect\@r@m@msize}\let\@seesize\@s@@size
- \advance\@tempdima-\@tarlinesep \advance\@tempdimb-\@tarlinesep
- \fi \setbox\@arstrutbox\hbox{% set up smaller strut
- \vrule \@height\@tempdima \@depth\@tempdimb \@width\z@}%
- \edef\@preamble{\ialign \noexpand\@halignto \bgroup
- \unhcopy\@arstrutbox \@preamble \tabskip\z@skip &\@sharp \cr}%
- % I have added an extra column (&\@sharp) to take the smart strut.
- \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
- \if#1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
- \bgroup \let\par\@empty
- \global\@arstheight\ht\@arstrutbox \global\@arstdepth\dp\@arstrutbox
- \advance\extrarulesep.5\arrayrulewidth
- \let\@sharp##\let\protect\relax \lineskip\z@skip \baselineskip\z@skip
- \@preamble}
-
- % Change the meaning of \\ to do the final strut calculation and
- % put in the smart strut
-
- \def\@xtabularcr{\@ifnextchar[{\@argtabularcr}{\@argtabularcr[\z@]}}
-
- \def\@xarraycr{\aftergroup\@argarraycr\@xtabularcr}
-
- \def\@argarraycr{${}}% put this "aftergroup" so we can combine macro streams
-
- % sense a following \hline, \cline or \end, and adjust spacing accordingly
-
- \def\@argtabularcr[#1]{\@ifnextchar\hline
- {\@mystrutcr\extrarulesep[#1]}% Note: \@tempc is next char from \@ifnextchar
- {\ifx\@tempc\cline \@mystrutcr\extrarulesep[#1]\else
- \ifx\@tempc\end \@mystrutcr-\@otarlinesep[#1]\else % reduce last strut
- \@mystrutcr\z@[#1]\fi\fi}}
-
- \def\@mystrutcr#1[#2]{\ifnum0=`{\fi}&\omit % end group, new column
- \advance\@arstheight\@skip@bove
- \ifdim#2>\z@ \advance\@arstdepth#2\fi \advance\@arstdepth#1%
- \advance\@arstheight\@tarlinesep \advance\@arstdepth\@tarlinesep
- \vrule \@height\@arstheight \@depth\@arstdepth \@width\z@
- \global\@arstheight\ht\@arstrutbox \global\@arstdepth\dp\@arstrutbox
- \global\@skip@bove\z@ \cr
- \ifdim#2<\z@ \noalign{\vskip#2}\fi}
-
- \let\@xargarraycr\@undefined \let\@yargarraycr\@undefined % save memory
-
- % Simulate \crcr at the end of the table, assuming that we are not in
- % vmode once a line of entries has started. This fails to put in a smart
- % strut if the table ends without \\ while in vmode in a column entry.
- % Use \@unrecurse to simulate grouping of global parameters.
- % For nested tables and arrays, the final strut is reduced by the linesep
- % that will be added at the outer level.
-
- \def\endtabular{\ifvmode\csname crcr\endcsname % just \crcr if \\ given...
- \else {\ifnum0=`}\fi\@mystrutcr-\@otarlinesep[\z@]% or simulate \\ when absent
- \fi\egroup\@unrecurse\egroup $\egroup}
-
- \expandafter\let\csname endtabular*\endcsname=\endtabular
-
- \def\endarray{\ifvmode\csname crcr\endcsname % like endtabular
- \else ${\ifnum0=`}\fi\aftergroup\@argarraycr\@mystrutcr-\@otarlinesep[\z@]%
- \fi\egroup\@unrecurse\egroup}
-
- % Put \@seesize...\@rememsize in all preamble templates
-
- \def\@tabclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
- \or \or \@addamp \or
- \@acolampacol \or \@firstampfalse \@acol \fi
- \edef\@preamble{\@preamble{%
- \ifcase
- \@chnum \hfil\@seesize\ignorespaces\@sharp\unskip\@rememsize \hfil
- \or \@seesize\ignorespaces\@sharp\unskip\@rememsize \hfil
- \or \hfil\hskip\z@skip\@seesize\ignorespaces\@sharp\unskip\@rememsize
- \fi}}}
-
- \def\@arrayclassz{\ifcase \@lastchclass \@acolampacol \or \@ampacol \or
- \or \or \@addamp \or
- \@acolampacol \or \@firstampfalse \@acol \fi
- \edef\@preamble{\@preamble
- \ifcase \@chnum
- \hfil\@seesize $\relax\@sharp$\@rememsize \hfil
- \or \@seesize $\relax\@sharp$\@rememsize \hfil
- \or \hfil\@seesize $\relax\@sharp$\@rememsize \fi}}
-
- \def\@classv{\@addtopreamble{\@seesize\@startpbox{\@nextchar}%
- \ignorespaces\@sharp\@endpbox\@rememsize}}
-
- % my macros to keep track of the size of entries.
-
- \def\@s@@size{\setbox\z@\hbox\bgroup}
-
- \def\@r@m@msize{\egroup % end the \hbox
- \ifdim\ht\z@>\@arstheight \global\@arstheight\ht\z@ \fi
- \ifdim\dp\z@>\@arstdepth \global\@arstdepth \dp\z@ \fi
- \unhbox\z@}
-
- % Redefine \hline to remove notches and to give extrarulesep and
- % optional [] skip
-
- \def\hline{\noalign{\ifnum0=`}\fi\kern-.5\arrayrulewidth
- \hrule \@height \arrayrulewidth \kern-.5\arrayrulewidth
- \futurelet\@tempa\@xhline}
-
- \def\@xhline{\global\@skip@bove\extrarulesep
- \ifx\@tempa\hline\vskip \doublerulesep\else
- \ifx\@tempa[\aftergroup\@yhline\fi\fi
- \ifnum0=`{\fi}}
-
- \def\@yhline[#1]{\noalign{\global\advance\@skip@bove#1}}
-
- % make \cline give the \extrarulesep below
-
- \def\cline#1{\noalign{\global\@skip@bove\extrarulesep}\@cline[#1]}
-
- \endinput
- % -----------------------------------------------------------------
- %
- % Modify LaTeX's array and tabular environments to keep text from touching
- % other text or hlines above or below. There are three new parameters:
- %
- % \tablinesep (or \tablelineskip): minimum space between text on successive
- % lines in a tabular environment. Negative distances are
- % treated as zero. The default value is 1pt. 0pt turns off
- % checking for touching text. Text given in an @{ }
- % specification is never checked for overlap.
- %
- % \arraylinesep (or \arraylineskip): like \tablinesep, but for arrays.
- %
- % \extrarulesep : extra space to add above and below each \hline and \cline.
- % There will be at least \extrarulesep + 0.5\tablinesep
- % between an \hline and a line of text. Negative values can
- % be used, but only until some text touches the line.
- % The default value is 3pt.
- %
- % To limit interline separations in tables but not arrays, declare
- % \setlength\arraylinesep{0pt}
- % The appearance of normal LaTeX tables can be had with
- % \setlength\tablinesep{0pt}
- % \setlength\arraylinesep{0pt}
- % \setlength\extrarulesep{0pt}
- % but it would be better to not use tabls in this situation.
- %
- % \hline[dimen]:
- %
- % \hline has been changed to take an optional length argument just like \\
- % giving the space to insert below. This space is in addition to the
- % \extrarulesep and linesep. A negative value will reduce the space until
- % the hline touches some text below, and then will have no further effect.
- % E.g., \hline[-9in] draws a horizontal line while suppressing the extrarulesep
- % beneath. Also, the new \hline FIXES THE NOTCHES that used to appear at the
- % junction between horizontal and vertical lines.
- %
- % How it works:
- % There are no struts in the preamble entries (lie), rather, there are
- % tests to measure the maximum height and depth of all entries on a line.
- % The maximum values start at the size of LaTeX's \@arstrut minus the
- % appropriate linesep. At the \\, a strut is inserted (in its own
- % column) which is that maximum size plus the linesep plus any additional
- % space for separation from \hline s.
- %
- % The Downside:
- % Building a table will be slower than before because the entries have to
- % be boxed twice (by \@seesize and by \halign itself) instead of just once.
- % \setlength\tablinesep{0pt} will recover most of this speed, with
- % \extrarulesep still partially in effect--extra space will still be added
- % around hlines, but it may be taken up by very tall or very deep table
- % entries; thus text may still touch the lines. Because of the speed penalty,
- % if your computer is slow, it is probably best to omit the TABLS option
- % until producing a final copy.
- %
- % (2.2) \endtabular* is defined (it was left out before. oops!)
- % change some \z@ to \z@skip. Thanks to Michael Downes.
- % Create alias \tablinesep = \tablelineskip for consistency with
- % \tabcolsep nomenclature. \def\\{\crcr} used in ver 2.1 didn't work right,
- % so use \csname crcr\endcsname.
- %
- % (3.0) Arrays are included! The very top and bottom struts of nested
- % arrays are reduced by the lesser of the inner and outer lineseps so space
- % doesn't accumulate with each level of nesting.
- %
- % (3.1 & 3.2) Minor changes to match LaTeX updates.
- %
- % Send problem reports to asnd@Reg.TRIUMF.CA
- %
- % Test integrity of file:
- % brackets: round, square, curly, angle: () [] {} <>
- % backslash, slash, vertical, at, dollar, and: \ / | @ $ &
- % hat, grave, acute (apostrophe), quote, tilde: ^ ` ' " ~
-